Using Scrollbars

I'm having a problem using the scroll bars function on the canvases. I actually have no idea how to use it!

void hasScrollbars etc..

i have a large image that is painted onto the canvas and I want to be able to scroll and see the whole image. How would I apply scroll bars to this? Does anyone have an example code with scroll bars I can take a look at? Thanks!
phan423 - Mon Jan 23 14:05:12 EST 2012

Re: Using Scrollbars
phan423 - Mon Jan 23 14:13:46 EST 2012

So how do I use that declaration

void hasScrollbars(DBE da,
void cb(DBE canv,
ScrollEvent Event,
ScrollSide scrollBar,
int newPos,
int oldPos))

and implement it with the different callbacks and possible event types?

Re: Using Scrollbars
rain_bow - Mon Jan 23 15:23:02 EST 2012

For example look at: http://easyweb.easynet.co.uk/iany/consultancy/dxl_graphics/dxl_graphics.htm

Re: Using Scrollbars
phan423 - Mon Jan 23 18:04:35 EST 2012

rain_bow - Mon Jan 23 15:23:02 EST 2012
For example look at: http://easyweb.easynet.co.uk/iany/consultancy/dxl_graphics/dxl_graphics.htm

theres nothing about scrollbars in that link you sent me. am I seeing this wrong?

Re: Using Scrollbars
Peter_Albert - Tue Jan 24 03:07:16 EST 2012

phan423 - Mon Jan 23 18:04:35 EST 2012
theres nothing about scrollbars in that link you sent me. am I seeing this wrong?

Hi,

scrollbars are extremely poorly documented. Attached is what I found out to be working a long time ago. Please read the commments, and then try the following (make sure to alter the include path as necessary).

Caveat: I think I wrote this while still using DOORS 7.x. Actually, I hardly ever used it, and now, on DOORS 8.3, I encountered a new problem: Scrolling down works, but when you stop scrolling, the canvas jumps back to the top. Don't know why this happens now, or if there is a more easy solution in DOORS 8 or 9 available. But still, you can give it a try.

Regards,

Peter

// Example program for using scrollbars with canvases
/*
  The comment lines à la
  // Comment 1) are w.r.t. to the Comments in the comment section
  of the include file
*/
// Comment 1)
#include <../addins/include/canvas_scrollbar.inc>
// ----------------------------------------------------------------------
pragma runLim, 0
// ----------------------------------------------------------------------
// Comment 4)
void repaint(DBE dbe)
{ // Repaint routine for canvas
  realBackground (dbe, realColor_White)
  realColor(dbe,realColor_Green)
  box(dbe, 100, 100, 300, 300)
  realColor(dbe,realColor_Black)
  rectangle(dbe, 0, 0, 10, 10)
  rectangle(dbe, 590, 0, 10, 10)
  rectangle(dbe, 0, 590, 10, 10)
  rectangle(dbe, 590, 590, 10, 10)
} // Repaint routine for canvas
// ----------------------------------------------------------------------
void scrollBarExample()
{ // Example code for using scrollbars with canvases
  DB exampleDB = create("Example for using scrollbars with canvases")
  // Comment 5)
  DBE cnvs = canvas(exampleDB, 200, 200, scrollCanvasRepaint)
  // Comment 2)
  hasScrollbars(cnvs, scrollCallBack)
  // Comment 6
  // The following three lines can be uncommented to force the size of the
  // complete canvas; default is to calculate the complete size.
  //totalDrawAreaHeight = 600
  //totalDrawAreaWidth = 600
  //autoCalcCanvasSize = false
 
  // Comment 3)
  realize exampleDB
  scrollCallBack(cnvs, scrollToPos, horizontal, 0, 0)
  scrollCallBack(cnvs, scrollToHome, vertical, 0, 0)
  show exampleDB
} // Example code for using scrollbars with canvases
// ----------------------------------------------------------------------
scrollBarExample()

Attachments

attachment_14781544_canvas_scrollbar.inc

Re: Using Scrollbars
phan423 - Tue Jan 24 12:30:52 EST 2012

Peter_Albert - Tue Jan 24 03:07:16 EST 2012

Hi,

scrollbars are extremely poorly documented. Attached is what I found out to be working a long time ago. Please read the commments, and then try the following (make sure to alter the include path as necessary).

Caveat: I think I wrote this while still using DOORS 7.x. Actually, I hardly ever used it, and now, on DOORS 8.3, I encountered a new problem: Scrolling down works, but when you stop scrolling, the canvas jumps back to the top. Don't know why this happens now, or if there is a more easy solution in DOORS 8 or 9 available. But still, you can give it a try.

Regards,

Peter

// Example program for using scrollbars with canvases
/*
  The comment lines à la
  // Comment 1) are w.r.t. to the Comments in the comment section
  of the include file
*/
// Comment 1)
#include <../addins/include/canvas_scrollbar.inc>
// ----------------------------------------------------------------------
pragma runLim, 0
// ----------------------------------------------------------------------
// Comment 4)
void repaint(DBE dbe)
{ // Repaint routine for canvas
  realBackground (dbe, realColor_White)
  realColor(dbe,realColor_Green)
  box(dbe, 100, 100, 300, 300)
  realColor(dbe,realColor_Black)
  rectangle(dbe, 0, 0, 10, 10)
  rectangle(dbe, 590, 0, 10, 10)
  rectangle(dbe, 0, 590, 10, 10)
  rectangle(dbe, 590, 590, 10, 10)
} // Repaint routine for canvas
// ----------------------------------------------------------------------
void scrollBarExample()
{ // Example code for using scrollbars with canvases
  DB exampleDB = create("Example for using scrollbars with canvases")
  // Comment 5)
  DBE cnvs = canvas(exampleDB, 200, 200, scrollCanvasRepaint)
  // Comment 2)
  hasScrollbars(cnvs, scrollCallBack)
  // Comment 6
  // The following three lines can be uncommented to force the size of the
  // complete canvas; default is to calculate the complete size.
  //totalDrawAreaHeight = 600
  //totalDrawAreaWidth = 600
  //autoCalcCanvasSize = false
 
  // Comment 3)
  realize exampleDB
  scrollCallBack(cnvs, scrollToPos, horizontal, 0, 0)
  scrollCallBack(cnvs, scrollToHome, vertical, 0, 0)
  show exampleDB
} // Example code for using scrollbars with canvases
// ----------------------------------------------------------------------
scrollBarExample()

Where is your scrollCallBack method? i keep getting an error that says the variables been undeclared.

this is what i have so far:
DBE cnv = canvas(canvasBox, 1500, 700, doRepaint)

void cb(DBE cnv,ScrollEvent Event,ScrollSide scrollBar,int newPos,int oldPos) {

}

hasScrollbars(cnv,cb)

cb(cnv, scrollToPos, horizontal, 0, 0)
cb(cnv, scrollToHome, vertical, 0, 0)

Re: Using Scrollbars
phan423 - Thu Jan 26 11:57:18 EST 2012

phan423 - Tue Jan 24 12:30:52 EST 2012
Where is your scrollCallBack method? i keep getting an error that says the variables been undeclared.

this is what i have so far:
DBE cnv = canvas(canvasBox, 1500, 700, doRepaint)

void cb(DBE cnv,ScrollEvent Event,ScrollSide scrollBar,int newPos,int oldPos) {

}

hasScrollbars(cnv,cb)

cb(cnv, scrollToPos, horizontal, 0, 0)
cb(cnv, scrollToHome, vertical, 0, 0)

anyone get scrollbars to work yet or know how to use them? please help

Re: Using Scrollbars
Peter_Albert - Mon Jan 30 03:19:34 EST 2012

phan423 - Thu Jan 26 11:57:18 EST 2012
anyone get scrollbars to work yet or know how to use them? please help

Please have a look to my earlier post. There was an include file attached to it, which contains all the routines.

Regards,

Peter